#ifndef CARD_H
#define CARD_H

#include <string>
#include <renderobject.h>

class CardSpot;
class CardEngine;
class Card : public RenderObject
{
public:
    enum Suit { Spades = 0, Hearts, Clover, Diamond, Special, SuitCount = 4 }; // Special for Joker etc?
    Card(Suit s, int r);
    Suit suit() const;
    int rank() const;
    void setCardSpot(CardSpot *spot);
    CardSpot *cardSpot() const;
    // ### map?
    const std::string &customData() const;
    void setCustomData(const std::string &data);
    void clearCustomData();
    bool isCovered() const;
    bool isRed() const { return data.suit == Hearts || data.suit == Diamond; }
    bool isBlack() const { return data.suit == Spades || data.suit == Clover; }
    enum Face { FaceUp, FaceDown };
    Face face() const;
    inline void flip(Face face) { setFace(face); }
    void setFace(Face face);
private:
    struct Data {
        Data(Suit s, int r) : suit(s), rank(r), face(FaceDown), cardSpot(0) {}
        const Suit suit;
        const int rank;
        Face face;
        CardSpot *cardSpot;
        std::string customData;
        Image *image;
    } data;
};

#endif
